<?php

class Silk_Zgb_Block_Renderer_Thumbnail extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
	public function render(Varien_Object $row)
	{
		$id =  $row->getData($this->getColumn()->getIndex());

		try {

			$product = Mage::getModel('catalog/product')->load($id);

			$websiteId = Mage::getSingleton('admin/session')->getUser()->getWebsiteId();

			if($websiteId){
				$storeId = Mage::getModel('core/website')->load($websiteId)->getDefaultStore()->getId();
				$product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($id);
				$productImg = Mage::helper('catalog/image')->init($product,'small_image')->resize(100);
			}else{
				$productImg = Mage::helper('catalog/image')->init($product,'small_image')->resize(100);
			}
		} catch (Exception $e){

			Mage::logException($e);

			$placeHolderImg = Mage::getStoreConfig("catalog/placeholder/small_image_placeholder");

			if(empty($placeHolderImg)){

				$productImg = "";

			}else{

				$productImg = Mage::getSingleton('catalog/product_media_config')->
							getBaseMediaUrl(). '/placeholder/' . $placeHolderImg;
			}
			
		}
			

		return '<img src="'.$productImg.'" style="width:100px;">';
	}
}